//保存部门前先验证表单数据是否合法
function validateMethod(){
    var deptName = $("#pk_t_2_1_osv").val();
    var name = $("#name_varchar").val();
    if(deptName == ""){
        alert("父级部门不能为空!");
        $("#pk_t_2_1_osv").focus();
        return false;
    }
    if(name == ""){
        alert("部门名称不能为空!");
        $("#name_varchar").focus();
        return false;
    }
}

//部门添加保存方法(xiaogq)
function saveDept(){
    $('#entity_form').ajaxForm({
        beforeSubmit:validateMethod,
        success:function(balkJson) {
            var flag = balkJson.flag;
            if(flag == "success"){
                parent.closeTab(1);
            }else{
                alert(flag);
            }
        },
        error:function (msg) {
            alert("添加部门异常!");
        }
    });
    $("#entity_form").submit();
}

//保存部门前先验证表单数据是否合法
function validEditDeptMethod(){
    var name = $("#name_varchar").val();
    if(name == ""){
        alert("部门名称不能为空!");
        $("#name_varchar").focus();
        return false;
    }
}

//部门编辑保存方法(xiaogq)
function saveEditDept(){
    $('#entity_form').ajaxForm({
        beforeSubmit:validEditDeptMethod,
        success:function(balkJson) {
            var flag = balkJson.flag;
            if(flag == "success"){
                parent.closeTab(1);
            }else{
                alert(flag);
            }
        },
        error:function (msg) {
            alert("编辑部门异常!");
        }
    });
    $("#entity_form").submit();
}